#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2505,B = 2400;
int n,m,c[N],t[N],w[N],f[100][N],g[100][N];
vector<pair<int,int> > vec[N];
signed main()
{
	freopen("book.in","r",stdin);
	freopen("book.out","w",stdout);
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n;
	for(int i = 1;i<=n;i++)
		cin>>c[i];
	for(int i = 1;i<=n;i++)
		cin>>t[i];
	for(int i = 1;i<=n;i++)
		cin>>w[i];
	cin>>m;
	for(int i = 1;i<=n;i++)
	{
		int now = 1,noww = 0;
		while(c[i]>=now) vec[noww].push_back({t[i],w[i]*now}),c[i]-=now,now*=2,noww++;
		for(int j = 0;j<=30;j++)
			if((c[i]>>j)&1) vec[j].push_back({t[i],w[i]*(1<<j)});
	}
	int lim = 0;
	while((m>>lim)) lim++;
	for(int i = 0;i<=lim;i++)
		for(auto _:vec[i])
		{
			int x = _.first,w = _.second;
			for(int j = B;j>=x;j--)
				f[i][j] = max(f[i][j],f[i][j-x]+w);
		}
	for(int i = 0;i<=B;i++) g[0][i] = f[0][i];
	for(int i = 1;i<=lim;i++)
		for(int j = B;~j;j--)
			for(int k = 0;k<=j;k++)
			{
				int x = (j-k)*2;
				if((m>>(i-1))&1) x++;
				int w = f[i][k];
				if(x<=B) w+=g[i-1][x];
				g[i][j] = max(g[i][j],w);
			}
	cout<<g[lim-1][1];
	return 0;
}

